﻿<%@ Page Language="VB" %>

<%@ Import Namespace="System.IO" %>

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not Request.Params("FileName") = "" Then
            DownloadFile(Request.Params("FileName"))
        Else
            Me.lblError.Text = "No file specified"
        End If
    End Sub
    
    Sub DownloadFile(ByVal strFileName As String)
 
        Try
            Response.AddHeader("content-disposition", "attachment;filename=""" & strFileName & """")
            Response.AddHeader("Content-type", "application/force-download")
            Response.WriteFile(strFileName)
            Response.End()
        Catch EXC As Exception
            Me.lblError.Text = EXC.Message
            
        End Try
    End Sub
</script>

<asp:label ID="lblError" runat="server" />